package com.xiaoyang.ssyx.product.controller;

import com.xiaoyang.ssyx.common.result.Result;
import com.xiaoyang.ssyx.product.service.FileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @AUTHOR XiaoYang
 * @DATE 2023/6/16-12:17
 * @DESCRIPTION TODO
 */
@Api(tags = "文件上传接口")
@RestController
//@CrossOrigin
@RequestMapping("admin/product")
public class FileUploadController {
    @Autowired
    private FileUploadService fileUploadService;

    //图片上传
    @ApiOperation("图片上传")
    @PostMapping("fileUpload")
    public Result fileUpload(MultipartFile file){
        String url = fileUploadService.uploadFile(file);
        return Result.ok(url);
    }


}
